/*
 * @Author: ૮₍ ˙О˙₎ა
 * @Date: 2023-07-20 09:44:54
 */
import type { IReqSpuList, ISpuImageList, ISpuPublic, ISpuSaleAttrList } from '@/types/spu'
import { http } from '@/utils/request'

/**
 * @description spu 列表
 * @returns
 */
export const reqSpuList = (page: number, limit: number, category3Id: number) => {
  return http<IReqSpuList>(`/admin/product/${page}/${limit}?category3Id=${category3Id}`, 'GET')
}

/**
 * @description spu 详情
 * @returns
 */
export const reqSpuDetail = (id: number) => {
  return http<ISpuPublic>(`/admin/product/getSpuById/${id}`, 'GET')
}

/**
 * @description spu 删除
 * @returns
 */
export const reqSpuDelete = (id: number) => {
  return http(`/admin/product/deleteSpu/${id}`, 'DELETE')
}

/**
 * @description spu 添加
 * @returns
 */
export const reqSaveSpuInfo = (data: ISpuPublic) => {
  return http(`/admin/product/saveSpuInfo`, 'POST', data)
}

/**
 * @description spu 编辑
 * @returns
 */
export const reqUpdateSpuInfo = (data: ISpuPublic) => {
  return http(`/admin/product/updateSpuInfo`, 'POST', data)
}

/**
 * @description spu 销售属性列表
 * @returns
 */
export const reqSpuSaleAttrList = () => {
  return http<ISpuSaleAttrList[]>(`/admin/product/baseSaleAttrList`, 'GET')
}

/**
 * @description 获取 spuId 图片列表
 * @returns
 */
export const reqSpuImageList = (spuId: number) => {
  return http<ISpuImageList[]>(`/admin/product/spuImageList/${spuId}`, 'GET')
}
